$(function () {
    $("#Deep").click(function () {
        $("#memo1").fadeOut();
        $("#memo2").fadeOut();
        let url = $("#distance")[0].value;
        if (url.length <= 0) {
            alert("站点名不能为空!");
            return
        }
        $.ajax({
            url: "deep",
            data: {
                url: url
            },
            success: function (result) {
                $("#mydata").fadeIn();
                console.log(result);
                $("#dataArea").empty();
                $("#imgarea").empty();
                $("#videoarea").empty();

                if (result["error"] === undefined) {
                    $("#memo1").fadeIn()
                } else {
                    $("#memo2").fadeIn()
                }
                for (i in result["link"]) {
                    let obj = result["link"][i];
                    let txt1 = $("<th style='width: 30%'></th>").text(obj["Title"]);
                    let txt2 = $("<th style='width: 70%'></th>").append("<a target='_blank' href='" + obj["Url"] + "'>" + obj["Url"] + "</a>");
                    let th = $("<tr></tr>");
                    th.append(txt1);
                    th.append(txt2);
                    $("#dataArea").append(th)
                }

                for (i in result["img"]) {
                    $("#imgarea").append("<a target='_blank' href='" + result["img"][i]["Url"] + "'><img style='width: 50px;height: 50px;' src='" + result["img"][i]["Url"] + "' class='img-rounded m-r-10 m-b-10'></a>")
                }

                for (i in result["video"]) {
                    let obj = result["video"][i];
                    let txt1 = $("<th style='width: 30%'></th>").text(obj["Title"]);
                    let txt2 = $("<th style='width: 70%'></th>").append("<a target='_blank' href='" + obj["Url"] + "'>" + obj["Url"] + "</a>");
                    let th = $("<tr></tr>");
                    th.append(txt1);
                    th.append(txt2);
                    $("#dataArea").append(th)
                }


            }
        });
    })
});

$(function () {
    $("#arch").click(function (e) {
        $.getJSON("arch", function (result) {
            if (result["error"] === undefined) {
                $("#arch").attr("disabled", "")
            }
            alert(result["message"])
        })
    })
});